package com.neusoft.yuejian_01.activity;

import android.content.Context;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.base.BaseActivity;
import com.neusoft.yuejian_01.javabean.ActivityRegBean;
import com.neusoft.yuejian_01.listener.RetrofitListener;
import com.neusoft.yuejian_01.model.ActivityModel;

public class ActivityRegActivity extends BaseActivity implements RetrofitListener {
    private TextView activityuserphoneView;
    private TextView activitypriceView;
    private TextView activitynameView;
    private TextView activityuserView;
    private ImageView activitypass;
    protected Context context;
    private ImageButton button_back;//返回按钮
    private int a_id;

    protected void initView() {
        setContentView(R.layout.activity_reg_activity);
        activityuserphoneView = (TextView) findViewById(R.id.activityphone);
        activitypriceView = (TextView) findViewById(R.id.activityprice);
        activitynameView = (TextView) findViewById(R.id.activityname);
        activityuserView = (TextView) findViewById(R.id.activityusername);
        button_back = (ImageButton) findViewById(R.id.button_back);
        activitypass = (ImageView) findViewById(R.id.activitypass);
    }
    protected void initEvents() {
        button_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                finish();

            }
        });
    }
    protected void initData() {
        a_id = getIntent().getIntExtra("a_id",-1);
        ActivityModel activityModel = new ActivityModel();
        activityModel.activityreg(String.valueOf(getUser_id()),String.valueOf(a_id),this);
    }
    @Override
    public void onSuccess(Object object, int flag) {

        ActivityRegBean activityRegBean = (ActivityRegBean) object;
        activityuserphoneView.setText(activityRegBean.getU_phone());
        activitypriceView.setText(String.valueOf(activityRegBean.getA_price()));
        activityuserView.setText(activityRegBean.getU_name());
        activitynameView.setText(activityRegBean.getA_name());
        if (activityRegBean.getAn_pass().equals("1")){
            //已审核
            activitypass.setImageResource(R.drawable.ic_checkeds);
        }
        else {
            //未审核
            activitypass.setImageResource(R.drawable.ic_checks);
        }
    }
    @Override
    public void onFail() {
        Toast.makeText(this,"fail",Toast.LENGTH_LONG).show();
    }
}
